package view.component.monster.large_monster
{
	import enums.main.UISize;
	
	import feathers.controls.Label;
	import feathers.controls.Screen;
	
	import model.vo.monster.MonsterIntroVo;
	
	import starling.animation.Tween;
	import starling.core.Starling;
	import starling.display.Image;
	import starling.text.TextField;
	import starling.utils.Color;
	
	import util.AtlasTextureGenerator;
	
	import view.component.IAnimateNaviView;
	
	
	
	/**
	 * 大型怪物详细-怪物介绍
	 * @author £iang
	 * 
	 */	
	public class LMDetailIntroductionView extends Screen implements IAnimateNaviView
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 怪物图标 */
		public var monsterImage:Image;
		/** 怪物中文名 */
		public var monsterCH:Label;
		/** 怪物日文名 */
		public var monsterJP:Label;
		/** 怪物介绍 */
		public var monsterIntro:TextField;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 初始化函数 
		 * 
		 */		
		override protected function initialize():void
		{
			this.alpha = 0;
			this.touchable = false;
			
			monsterCH = new Label();
			monsterCH.name = "largeTitleLabel";
			this.addChild( monsterCH );
			monsterJP = new Label();
			this.addChild( monsterJP );
			monsterJP.name = "smallTitleLabel";
			monsterIntro = new TextField( UISize.MAIN_W - UISize.CONTENT_H_PADDING * this.dpiScale, 
				UISize.MAIN_H - ( UISize.MONSTER_TAB_AREA_H + 
					UISize.LMONSTER_DETAIL_TAB_AREA_H + 120 ) * this.dpiScale, 
				"",  "微软雅黑,宋体", 24 * this.dpiScale, Color.WHITE, false );
			this.addChild( monsterIntro );
			monsterIntro.hAlign = "left";
			monsterIntro.vAlign = "top";
		}
		
		/**
		 * 调整组件 
		 * 
		 */		
		override protected function draw():void
		{
			monsterImage.x = UISize.CONTENT_H_PADDING * this.dpiScale;
			monsterImage.y = 20 * this.dpiScale;
			monsterCH.x = UISize.CONTENT_H_PADDING * 2 * this.dpiScale + 
				UISize.MONSTER_ICON_SIZE * this.dpiScale;
			monsterJP.x = monsterCH.x;
			monsterJP.y = ( UISize.CONTENT_V_PADDING + 40 ) * this.dpiScale;
			monsterIntro.y = 120 * this.dpiScale;
			monsterIntro.x = UISize.CONTENT_H_PADDING * this.dpiScale;
		}
		
		/**
		 * 播放显示动画
		 * 
		 */	
		public function playShowAnimate():void
		{
			var tween:Tween = new Tween( this, 0.4, "linear" );
			
			tween.animate( "alpha", 1);
			Starling.juggler.add( tween );
		}
		
		/**
		 * 播放隐藏动画 
		 * 
		 */	
		public function playHideAnimate():void
		{
			var tween:Tween = new Tween( this, 0.4, "linear" );
			
			tween.animate( "alpha", 0);
			Starling.juggler.add( tween );
		}
		
		/**
		 * 设置怪物介绍信息 
		 * @param introVo 怪物介绍vo
		 * 
		 */		
		public function setItroData( introVo:MonsterIntroVo ):void
		{
			monsterImage = new Image( AtlasTextureGenerator.getMonsterTextureById( "l", introVo.monsterId ) );
			this.addChild( monsterImage );
			monsterImage.scaleX = monsterImage.scaleY = this.dpiScale;
			monsterCH.text = introVo.ch;
			monsterJP.text = introVo.jp;
			monsterIntro.text = introVo.intro;
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构函数 
		 * 
		 */		
		override public function dispose():void
		{
			Starling.juggler.removeTweens( this );
			
			monsterImage.dispose();
			monsterImage.texture.dispose();
			monsterImage = null;
			
			monsterCH.dispose();
			monsterCH = null;
			
			monsterJP.dispose();
			monsterJP = null;
			
			monsterIntro.dispose();
			monsterIntro = null;
			super.dispose();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function LMDetailIntroductionView()
		{
			super();
		}
	}
}